package com.seari.monitor;

import java.util.concurrent.TimeUnit;

import com.seari.utils.ProcessUtil;

public abstract class MiddlewareMonitor {

	protected static final String START_SERVICE_COMMAND = "net start ";
	protected static final String END_SERVICE_COMMAND = "net stop ";
	
	public void startService(String midName) {
		ProcessUtil.executeCommand(START_SERVICE_COMMAND + midName);
	}
	
	public void restartService(String midName,long seconds){
		try {
			
			ProcessUtil.executeCommand(END_SERVICE_COMMAND + midName);
			TimeUnit.SECONDS.sleep(seconds);
			ProcessUtil.executeCommand(START_SERVICE_COMMAND + midName);
			TimeUnit.SECONDS.sleep(5);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public abstract boolean isClient();
	
	public abstract void monitorData();
}
